Skip to content

feat(databases): add --catalog flag to databases create#125

Merged
eddietejeda merged 3 commits into
mainfrom
feat/databases-create-default-catalog
Jun 4, 2026
Merged

feat(databases): add --catalog flag to databases create#125
eddietejeda merged 3 commits into
mainfrom
feat/databases-create-default-catalog

Conversation

@eddietejeda
Copy link
Copy Markdown
Contributor

Summary

  • Adds --catalog flag to databases create, mapping to default_catalog on POST /v1/databases
  • Separates the human-readable --name (display name) from the SQL catalog alias used in queries (SELECT * FROM <catalog>.schema.table)
  • CreateDatabaseResponse now deserializes default_catalog and displays it in table output
  • Fixes config tests that failed locally when HOTDATA_API_KEY was set in the environment

Usage

hotdata databases create   --name "Sales reporting"   --catalog analytics

Test plan

  • databases create --name "..." --catalog <alias> — API receives default_catalog, response round-trips, table output shows catalog: line and query hint uses catalog name
  • databases create --name "..." (no catalog) — unchanged behaviour
  • databases create --catalog <alias> (no name) — works, name shown as null
  • Invalid catalog name (spaces) — clean server error returned
  • All 13 config tests pass locally with HOTDATA_API_KEY set

Maps to the default_catalog field on POST /v1/databases, separating
the human-readable --name from the SQL catalog alias used in queries.

Also fixes config tests that failed when HOTDATA_API_KEY was set in the
environment by unsetting it inside the with_temp_config_dir test helper.
@sentry
Copy link
Copy Markdown

sentry Bot commented Jun 4, 2026

Codecov Report

❌ Patch coverage is 43.75000% with 27 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/databases.rs 40.47% 25 Missing ⚠️
src/main.rs 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread src/databases.rs
Comment on lines +162 to +168
if let Some(c) = catalog {
req.insert(
"default_catalog".to_string(),
serde_json::Value::String(c.to_string()),
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the new default_catalog request branch has no test coverage. Every create_database_request test call passes None for the catalog arg, so this insert is never exercised. Consider adding a test like create_database_request(None, Some("analytics"), "public", &[], None) asserting req["default_catalog"] == "analytics". (not blocking)

Comment thread src/databases.rs
Comment on lines +618 to +620
let catalog = result.default_catalog.as_deref()
.or(result.name.as_deref())
.unwrap_or("default");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: now that name is a free-form display string (e.g. "Sales reporting"), this fallback can put an invalid catalog into the query hint. If the server returns a name but no default_catalog, the hint becomes SELECT * FROM Sales reporting.public.<table> — which won't parse. Falling back to "default" (or omitting the hint) would be safer than falling back to the display name.

Same conflation still exists in get (line 435, let catalog = db.name.as_deref()... for sql_prefix) and the list empty-state hint (line 396, --name <catalog_name>), which now read as stale given this PR's name/catalog split. Worth a follow-up if DatabaseInfo can surface default_catalog. (not blocking)

claude[bot]
claude Bot previously approved these changes Jun 4, 2026
Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-scoped change. Two non-blocking nits left inline (test coverage for the new default_catalog request branch, and the display-name fallback in the query hint now that name is free-form).

claude[bot]
claude Bot previously approved these changes Jun 4, 2026
Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The --catalog flag is wired through cleanly and the request/response changes are correct. The two outstanding nits (untested default_catalog branch, and the name-as-catalog fallback in the query hint / get / list empty-state) are already captured in existing threads and remain non-blocking.

…n all output

- Add `default_catalog` field to `Database` struct so `databases show`
  and table commands use the correct SQL alias instead of falling back
  to the display name
- Use default_catalog (falling back to name, then "default") in
  databases show sql_prefix, tables list full_name, tables load, and
  tables delete output
- Fix --catalog arg doc: remove stale 24h expiry claim
- Update README and skills/hotdata/SKILL.md to document --name as
  display name and --catalog as the SQL alias, with corrected examples
Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the --catalog flag addition. The flag is wired correctly end-to-end (command.rsmain.rsdatabases::createcreate_database_request), all call sites and tests are updated for the new arg, and the default_catalog field round-trips through both Database and CreateDatabaseResponse. The config test fix (clearing HOTDATA_API_KEY) is sound. The two existing nit threads (test coverage for the default_catalog request branch; display-name fallback in query hints) are non-blocking. LGTM.

@eddietejeda eddietejeda merged commit 4a253d8 into main Jun 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant